package com.buka.util;

import com.buka.config.MinioConfig;
import io.minio.MinioClient;
import io.minio.ObjectStat;
import io.minio.PutObjectArgs;
import io.minio.errors.*;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

@Component
public class MinioUtil {


    @Resource
    MinioClient client;

    //创建桶的方法

    //删除桶

    //上传文件
    public void putFile(String bucketName, String objectName, InputStream in,Long fileSize,String type) throws ServerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
        PutObjectArgs objectArgs = PutObjectArgs.builder()
                .bucket(bucketName)
                .stream(in, fileSize, -1)
                .contentType(type).object(objectName)
                .build();
        client.putObject(objectArgs);
    }

    //获取文件信息

    //创建文件夹

}
